import Index from 'comps/index';
import ConsoleApp from 'comps/console';
import ConsoleDashboard from 'comps/dashboard/containers/main';
import MachineManage from 'comps/machine-manage/containers/machine-search-list';
import UserManage from 'comps/user-manage';
import DevTeamManage from 'comps/dev-team/containers/dev-team-manage-list';
import RunnableGroupManage from 'comps/runnable-group/containers/runnable-group-manage';
import CompanyManage from 'comps/company-manage/containers/company-list';
import CompanyAdmin from 'comps/company-admin/containers/company-list';
import Profile from 'comps/profile/containers/user-profile';
import UserInfo from 'comps/profile/containers/user-info';
import DubboProfilerLayer from 'comps/dubbo-profiler';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';

const AppRouter = () => {
  return (
    <Router history={browserHistory}>
      <Route path='/' component={Index}/>
      <Route path='/index' component={Index}/>

      <Route path='/console' component={ConsoleApp}>
        <IndexRoute components={{ title: () => <span>工作台</span>, children: ConsoleDashboard }}/>
        {/*
         因为 components 必须是合法的 React Component ，而 React Component 不能直接返回字符串，所以使用一个返回 span 包裹的字符串的 stateless component
         如果有更好的方式再替换
         */}
        <Route path='/profile' components={{ title: () => <span>用户信息</span>, children: Profile }}/>
        <Route path='/u/:userId' components={{ title: () => <span>用户信息</span>, children: UserInfo }}/>

        <Route path='my-dev-teams' components={{ title: () => <span>我的开发组</span>, children: DevTeamManage }}/>
        <Route path='my-runnable-groups' components={{ title: () => <span>我的项目</span>, children: RunnableGroupManage }}/>
        <Route path='machine-manage' components={{ title: () => <span>机器管理</span>, children: MachineManage }}/>
        <Route path='user-manage' components={{ title: () => <span>用户管理</span>, children: UserManage }}/>
        <Route path='company-manage' components={{ title: () => <span>企业管理</span>, children: CompanyManage }}/>
        <Route path='dubbo-profiler' components={{ title: () => <span>服务治理</span>, children: DubboProfilerLayer }}/>
        <Route path='company-admin' components={{ title: () => <span>我维护的企业</span>, children: CompanyAdmin }}/>
      </Route>
    </Router>
  );
};

export default AppRouter;
